package com.ruoyi.http.controller;

import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.data.SysParamKey;
import com.ruoyi.data.domain.ParameterSingleT;
import com.ruoyi.data.service.IParameterSingleService;
import com.ruoyi.http.domain.WeChat01600T;
import com.ruoyi.http.service.IWeChatTService;
import com.ruoyi.util.FileUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/http/weChat01600")
public class WeChat01600 extends BaseController {

    @Autowired
    private IWeChatTService weChatTService;
    @Autowired
    private IParameterSingleService parameterSingleService;
    @PostMapping("/weChat")
    public AjaxResult http(WeChat01600T weChat01600T) {
        WeChat01600T weChat = new WeChat01600T();
        String date1 = "正面身份证_"+System.currentTimeMillis();
        String date2 = "反面身份证_"+System.currentTimeMillis();
        String date3 = "房产证_"+System.currentTimeMillis();
        FileUtil.base64ToJpg(RuoYiConfig.getCardPhoto(),weChat01600T.getFrontIdCard().split(",")[1],date1,"jpg");
        FileUtil.base64ToJpg(RuoYiConfig.getCardPhoto(),weChat01600T.getHomeCard().split(",")[1],date3,"jpg");
        FileUtil.base64ToJpg(RuoYiConfig.getCardPhoto(),weChat01600T.getVersoIdCard().split(",")[1],date2,"jpg");
        weChat01600T.setFrontIdCard(weChat01600T.getFrontIdCard().split(",")[1]);
        weChat01600T.setHomeCard(weChat01600T.getHomeCard().split(",")[1]);
        weChat01600T.setVersoIdCard(weChat01600T.getVersoIdCard().split(",")[1]);
        weChat01600T.setFrontIdcardname("正面身份证");
        weChat01600T.setHomecardname("房产证");
        weChat01600T.setVersoIdcardname("反面身份证");
        weChat01600T.setFrontIdcardhttp(date1);
        weChat01600T.setHomecardhttp(date3);
        weChat01600T.setVersoIdcardhttp(date2);
        weChatTService.insertInformation(weChat01600T);
        return AjaxResult.success(weChat);
    }
}